﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{ 
    public class TECHWS05Data : BaseFunction
    {


        public TECHWS05Data()
            : base()
        {

        }

        public TECHWS05Data(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {
        } 

        public DataSet BuildData()
        {
            DataSet setReturn = new DataSet();
            DataSet dsResult = new DataSet();
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT * FROM FINISHING_ORDER ";
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "FINISHING_ORDER";

                    byte[] b;
                    string value;
                    string column = "";
                    foreach (DataRow dw in dsResult.Tables["FINISHING_ORDER"].Rows)
                    {
                    
                            column = "ABPBESCHICH";
                            b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw[column].ToString().Trim());
                            value = Encoding.GetEncoding("gb2312").GetString(b);
                            dw[column] = value; 
                            column = "COMPOSITION";
                            b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw[column].ToString().Trim());
                            value = Encoding.GetEncoding("gb2312").GetString(b);
                            dw[column] = value; 
                            column = "FACTORY";
                            b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw[column].ToString().Trim());
                            value = Encoding.GetEncoding("gb2312").GetString(b);
                            dw[column] = value; 
                    }
                }
                setReturn.Merge(dsResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
    }
}